<?php
// Application constants
define('IMAGE_VERSION_SMALL', 'small');
define('IMAGE_VERSION_MEDIUM', 'medium');
define('IMAGE_VERSION_LARGE', 'large');

// Application configuration
return array(
	'basePath'=>dirname(__FILE__).'/..',
	'name'=>'Kuvakilpailut.net - Äänestä ja kommentoi suosikki kuviasi',
	'language'=>'fi_FI',
	'timeZone'=>'Europe/Helsinki',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
		'ext.bootstrap.components.*',
		//'ext.debugtoolbar.XWebDebugRouter',
		'application.modules.image.components.*',
		'application.modules.image.models.Image',
	),
	
	'behaviors'=>array(
		//'ext.lesscss.LessCompilationBehavior',
		//'application.components.facebook.FacebookAutoLoginBehavior',
	),

	'modules'=>array(
		'image'=>array(
            'createOnDemand'=>true, // requires apache mod_rewrite enabled
            'install'=>true, // allows you to run the installer
        ),
		'admin',
		// uncomment the following to enable the Gii tool
		/*
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'1234',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		*/
	),

	// application components
	'components'=>array(
		'user'=>array(
			'class'=>'WebUser',
			'allowAutoLogin'=>true, // enable cookie-based authentication
		),
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<id:\d+>'=>'entry/view',
				'contact'=>'site/contact',
				'<page:\w+>'=>'site/page/view/<page>',
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		'image'=>array(
            'class'=>'ImgManager',
			'versions'=>array(
				IMAGE_VERSION_SMALL=>array(
					'width'=>100,
					'height'=>100,
					'format'=>'jpg',
					'resizeMethod'=>'adaptiveResize',
				),
				IMAGE_VERSION_MEDIUM=>array(
				   'width'=>210,
				   'height'=>210,
				   'format'=>'jpg',
				   'resizeMethod'=>'adaptiveResize',
				),
				IMAGE_VERSION_LARGE=>array(
				   'width'=>640,
				   'height'=>640,
				   'format'=>'jpg',
				),
			),
        ),
		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=kuvakilpailut',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',
			'charset' => 'utf8',
		),
		'fb'=>array(
			'class'=>'application.components.facebook.FacebookConnect',
			'appId'=>'238860292825926',
			'appSecret'=>'20ade90f06227115bbb4a479a486218a',
		),
		'mailer' => array(
			'class' => 'ext.mailer.EMailer',
			'pathViews' => 'application.views.email',
			'pathLayouts' => 'application.views.email.layouts'
		),
		/*
		'lessCompiler'=>array(
			'class'=>'ext.lesscss.LessCompiler',
			'importPath'=>'css/less/',
			'paths'=>array(
				'css/less/style.less'=>'css/style.css',
				'css/less/admin.less'=>'css/admin.css',
			),
		),
		*/
		'bbcodeParser'=>array(
			'class'=>'ext.bbcode.BBCodeParser',
			'customToHtml'=>array(
				array('/:\)/'=>'<img src="/kuvakilpailut/images/emoticons/emotion-happy.png" />'),
				array('/:\(/'=>'<img src="/kuvakilpailut/images/emoticons/emotion-unhappy.png" />'),
				array('/;\)/'=>'<img src="/kuvakilpailut/images/emoticons/emotion-wink.png" />'),
				array('/:D/'=>'<img src="/kuvakilpailut/images/emoticons/emotion-smile.png" />'),
				array('/:O/'=>'<img src="/kuvakilpailut/images/emoticons/emotion-surprised.png" />'),
			),
			'customFromHtml'=>array(
				array('/\<img src="(.*?)happy.png" \/\>/'=>':)'),
				array('/\<img src="(.*?)unhappy.png" \/\>/'=>':('),
				array('/\<img src="(.*?)wink.png" \/\>/'=>';)'),
				array('/\<img src="(.*?)smile.png" \/\>/'=>':D'),
				array('/\<img src="(.*?)surprised.png" \/\>/'=>':O'),
			),
		),
		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),

	'params'=>require('params.php'),
);